<%@page import="model.environment.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<% 	PageViewInfo pvi = new PageViewInfo(); 
	pvi.setPageTitle("Checkout"); %>
<%@include file="parts/header.jsp" %>
	<div class="content"><%
		Object sessionMessage = session.getAttribute("pviMessage");
		if (sessionMessage == StaticInfo.Message.CHECKOUT_FAILED || sessionMessage == StaticInfo.Message.CHECKOUT_MIXED)
		{
			session.setAttribute("pviMessage", null); %>
			<div>
				<h3 style="text-align:left;">An error occurred with following items:</h3>
			</div> 
		
			<%
			ShoppingBasket basket = ShoppingBasket.getShoppingBasket(request.getSession());
			Map<Integer, Integer> map = basket.getHashMap();
			
			int count = 0;
			for (Integer j : map.keySet())
			{
				count++;
				Item i = Items.getItem(j); 
			%>	
				
			<div style="width:700px;border-top:1px solid black;float:left;">
				<div style="width:210px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:left;"><a href='<%= request.getContextPath() %>/showItem.jsp?itemID=<%=i.getItemID()%>'><%=i.getItemName()%></a> </h3>
				</div>    
				<div style="width:139px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:center;"><img src="<%=i.getThumbImageURL()%>" alt= "<%=i.getItemName()%>"></h3>
				</div>
				<div style="width:99px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:center;"> Price: <%= i.getItemPrice()%></h3>
				</div>
				<div style="width:99px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:center;">Stock: <%= i.getItemStock()%></h3>
				</div>
				<div style="width:149px;float:left;">
					<h3 style="text-align:center;"><a href='addToBasket.do?itemID=<%=i.getItemID()%>'>Add to basket</a></h3>
				</div>
			</div>
			<%}%>
				<div style="width:149px;float:left;">
					<h3 style="text-align:left;"><a href='<%= request.getContextPath() %>/basket.jsp'>Go back to basket</a> </h3>
				</div>    
			<%
		} else if (sessionMessage == StaticInfo.Message.CHECKOUT_OK) {
			session.setAttribute("pviMessage", null); %>
			<div>
				<h3 style="text-align:left;">Thanks for shopping at Apocalypse Store.</h3>
			</div> 
		<%} else { 
			response.sendRedirect("basket.jsp");
		}%>
		
 	</div>
<%@include file="parts/footer.jsp" %>